import { createI18n } from 'vue-i18n'
import type { App } from 'vue'
import { getLanguage } from '@/utils/cache'
import zhCN from './lang/zh-CN.json'
import enUS from './lang/en-US.json'
import zhTW from './lang/zh-TW.json'

const messages = {
	'zh-CN': {
		...zhCN
	},
	'en-US': {
		...enUS
	},
	'zh-TW': {
		...zhTW
	}
}

export const i18n = createI18n({
	locale: getLanguage(),
	legacy: false,
	messages
})

export const setupI18n = async (app: App) => {
	app.use(i18n)
}
